<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>LB-Admin1.0</title>
        {include file="header"}
        <style>
            h2{margin:8px 0}
            .no-sel{margin:0 4px;background-color:#fff;border:1px solid #ccc;color:#333;padding:6px 10px;}
            .work{background-color:#0099cc;color:#fff;}
            .county-list{padding:10px;min-height:40px;display:flex;justify-content:around-space;flex-wrap:wrap;}
            .county-list div{margin-top:10px;height:30px}
        </style>
    </head>
    <body>
        <div class="layui-bg-white layui-page">
  <form class="layui-form layui-card">
  <table class="layui-table" lay-skin="line" >
    <tbody>
      <tr>
        <td style="width:80px"><label class="layui-required">单位名称</label></td>
        <td><input type="text" name="name" value="{$data.name|default=''}" required lay-verify="required" placeholder="请输入单位名称" autocomplete="off" class="layui-input"></td>
       </tr>
      <tr>
        <td>联系地址</td>
        <td><input type="text" name="address" value="{$data.address|default=''}" placeholder="" autocomplete="off" class="layui-input"></td>
      </tr>
      <tr>
        <td>联系电话</td>
        <td><input type="text" name="tel" value="{$data.tel|default=''}" autocomplete="off" class="layui-input"></td>
      </tr>
      <tr>
        <td>备注</td>
        <td><input type="text" name="memo" id="memo" value="{$data.memo|default=''}" placeholder="" autocomplete="off" class="layui-input"></td>
      </tr>
      <tr>
        <td></td>
        <td colspan="3">
            <input type="hidden" name="id" value="{$data.id|default=''}">
            <button class="layui-btn" lay-submit lay-filter="editfrm">立即提交</button>
        </td>
      </tr>
    </tbody>
  </table>
</form>
</div>
<script>
//Demo
layui.use(['form','laydate'], function(){
  var form = layui.form;
  layui.form.render();
  var laydate = layui.laydate;
 
  form.on('submit(editfrm)', function(data){
    console.log(data.field)
    var countyarr=[];
    $(".work").each(function(item,index){
        var v=$(this).data('id')
        countyarr.push(v)
    })
    var countys=countyarr.join(',')
    var formData=data.field;    //return false;
    $.post("{:url('modify')}",data.field,function(res){
        console.log(res)
      if(res.code==1)  
      {
          layer.msg("保存成功",{icon:1,time:1000},function(){
             var index = parent.layer.getFrameIndex(window.name);
             window.parent.location.reload();
             parent.layer.close(index);
          });
      }
      else
      {
          layer.msg('失败');
      }
    })
    //});
    return false;
    });
});
$(function(){
    $(".no-sel").each(function(item,index){
        var v=$(this).data('id')
        d_county.forEach(item=>{
            if(v==item)
            {
                $(this).addClass('work')
            }
        })
    })
})
</script>
{include file="footer"}